package com.smartEdu.service.impl.web;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;

import com.smartEdu.commons.LogCvt;
import com.smartEdu.dao.UserParamDao;
import com.smartEdu.model.UserParamModel;
import com.smartEdu.po.UserInfoPo;
import com.smartEdu.service.LoginService;
import com.smartEdu.vo.web.LoginVo;

@Service(value="loginServiceWeb")
public class LoginServiceImpl implements LoginService{
	@Autowired
	@Qualifier(value="userParamDaoImpl")
	private UserParamDao userParamDao;

	@Override
	public boolean loginauth(LoginVo loginVo) {
		try {
			UserParamModel userParamModel = new UserParamModel();
			userParamModel.setId(loginVo.getUsername());
			UserInfoPo po = userParamDao.CheckPasswd(userParamModel);
			String dbPasswd = po.getPassword();
			loginVo.setLoginname(po.getLoginname());
			if (!loginVo.getUsername().equals("") && loginVo.getPassword().equalsIgnoreCase(dbPasswd)) {
				loginVo.setLoginname(po.getLoginname());
				return true;
			}
		}
		catch(Exception e) {
//			LogCvt.error(e.getMessage(),e);
			return false;
		}
		return false;
		
	}
	
}
